home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1994 / MacHack 1994.toast / MacHack™94 / Miscellaneous / Randy Thelen / ThreadedSort / Misc Stuff / Exceptions.cp next >
Encoding:
Text File  |  1994-06-26  |  1.6 KB  |  68 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        Exceptions.c
  3.  
  4.     Contains:    exception handling stuff
  5.                 Brutally stolen from the Finder 7.1 sources
  6.                 Brutally restolen from the Star Trek runtime stuff
  7.  
  8.     Written by:    Bruce Horn, Steve Capps, Larry Kenyon,
  9.                 John Meier, scott douglass, Darin Adler,
  10.                 Paul Mercer, Bryan Stearns, Dave Owens, Alan Mimms
  11.  
  12.     Copyright:    © 1988-1990, 1993 by Apple Computer, Inc., all rights reserved.
  13.  
  14.     Change History (most recent first):
  15.  
  16.          <1>     6/15/93    ABM        first checked in
  17.          <3>    12/10/92    dho        afterProto
  18.          <2>     9/30/92    dho        move exceptions out of partition globals
  19.         <3+>     8/21/92    dho        8.3
  20.          <3>     8/17/92    dho        use gFinderGlobals instead of gPartitionGlobals
  21.          <2>     7/31/92    dho        stub out asssembly exception calls
  22.          <1>     7/24/92    dho        First checked in for Star Trek
  23.         2/22/89        sad        make Fail FAIL even if error == noErr
  24.         2/1/89        sad        use dbgExceptionBreak
  25.         12/15/88    dba        get rid of PRINT on FailNil
  26.         10/25/88    JRM        add PRINT to Fail()
  27.         9/11/88        JRM        use moretypes
  28.         8/29/88        dba        added Fail
  29.         8/19/88        dba        added FailMemError, FailResError, and FailResourceNil
  30.  
  31.     To Do:
  32. */
  33.  
  34. #include <Types.h>
  35. #include <assert.h>
  36.  
  37. #include "Exceptions.h"
  38.  
  39.  
  40. TException * gExceptionStack = (TException *) nil;
  41.  
  42.  
  43. TException::TException()
  44. {
  45.     fNext = gExceptionStack;
  46.     gExceptionStack = this;
  47. }
  48.  
  49. TException::~TException()
  50. {
  51.     Pop();
  52. }
  53.  
  54. void TException::Pop()
  55. {
  56.     gExceptionStack = fNext;
  57. }
  58.  
  59. void Fail()
  60. {
  61.     TException *    currentException = gExceptionStack;
  62.     
  63.     assert(currentException != nil);
  64.  
  65.     currentException->Pop();            //    go back to previous handler
  66.     longjmp(currentException->fEnv,1);    //    warp nine Mr. Sulu
  67. }
  68.